<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/public.css" media="all">
    <style>
        body { background-color: #ffffff; }
        #editor—wrapper {
            border: 1px solid #ccc;
            z-index: 100; /* 按需定义 */
        }
        #toolbar-container { border-bottom: 1px solid #ccc; }
        #editor-container { height: 300px; }
    </style>
</head>
<body>
<div class="layuimini-container" id="app">
    <div class="layuimini-main">
        <div class="layui-form">
            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                <legend>修改用户信息</legend></fieldset>
            <div class="layui-form-item">
                <label class="layui-form-label required">绑丁手机号吗</label>
                <div class="layui-input-block">
                    <input type="text" lay-verify="required"
                           v-model="detail.mobile"
                           class="layui-input"
                    >
                </div>
            </div>
            <div class="layui-form-item">

            <label class="layui-form-label required">实名名称</label>
                <div class="layui-input-block">
                    <input type="text" lay-verify="required"
                           v-model="detail.real_name"
                           class="layui-input"
                    >
                </div>
            </div>
            <div class="layui-form-item">
            <label class="layui-form-label required">身份证号码</label>
                <div class="layui-input-block">
                    <input type="text" lay-verify="required"
                           v-model="detail.identity_code"
                           class="layui-input"
                    >
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn" id="submitBtn">提交修改</button>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="/js/common.js?v=5" charset="utf-8"></script>
<script>
    layui.use(['form'], function () {
        var form = layui.form, layer = layui.layer, $ = layui.$;
        new Vue({
            el:"#app",
            data: {
                detail:{
                    id:urlParam('id'),
                    ids:urlParam('ids'),
                    phone:null,
                    password:null,
                    mobile:null,
                    identity_code:null,
                    real_name:null
                }
            },
            methods:{
            },
            mounted:function(){
                var _this = this;
                var id = urlParam("id")
                _this.detail.id = id;
                if (id){
                    $.get('/admin/channelCustomer/'+id,{},function(res){
                        _this.detail = res.data;
                    })
                }
                var btn = $('#submitBtn');
                //监听提交
                form.on('submit(saveBtn)', function (data) {
                    btn.attr('disabled',true)
                    btn.addClass('layui-btn-disabled')
                    var loading = layer.load()
                    if (_this.detail.identity_code.length !== 18) {
                        // 长度不为 18，进行相应处理，
                        layer.msg('身份证号码长度不正确');
                        return  false;
                    }
                    if (_this.detail.mobile.length !== 11) {
                        // 长度不为 11，进行相应处理，
                        layer.msg('手机号码长度不正确');
                        return  false;
                    }
                    var formData = _this.detail;
                    formData._method = 'put';
                    $.post('/admin/channelCustomer/'+id+"/edit",formData,function (res) {
                        layer.close(loading)
                        btn.removeAttr('disabled')
                        btn.removeClass('layui-btn-disabled')
                        if (res.code ===0 ){
                            layer.msg('操作成功',{icon:6,time:500},function () {
                                parent.location.reload();
                            })
                        } else {
                            layer.msg(res.msg,{icon:5})
                        }
                    })
                    return false;
                });
                form.render();
            },
            updated:function(){
                form.render();
            }
        })
    });
</script>
</body>
</html>